package web.beans;

import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.ValidatorException;

public class UserBean implements java.io.Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 2371219938762936945L;
	
	private String user;
	private String password;
	private String mail;
	
	public String getMail() {
		return mail;
	}
	public void setMail(String mail) {
		this.mail = mail;
	}
	public String getUser() {
		return user;
	}
	public void setUser(String user) {
		this.user = user;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	
	public String doLogin(){
		
		return "OK";
		
	}
	
	public void validaPassword(FacesContext context, UIComponent component, Object value)  throws ValidatorException {
		
		String valor=(String) value;
		
		if(valor.length()<1){
			FacesMessage message = new FacesMessage();
            message.setSeverity(FacesMessage.SEVERITY_ERROR);
            message.setSummary("Email is not valid.");
            message.setDetail("Email is not valid.");
            context.addMessage("userForm:Email", message);
            throw new ValidatorException(message);
		}
	}

}
